# 重写JWT响应结果的方法
from rest_framework.response import Response
def jwt_response_payload_handler(token, user=None, request=None):
    return {
        'token': token,
        'username': user.username,
        'id':user.id
    }


from rest_framework.pagination import PageNumberPagination
class PageNum(PageNumberPagination):
    '''
    自定义分页器
    '''
    page_size_query_param = 'pagesize'
    max_page_size = 10

    def get_paginated_response(self, data):
        return Response({
            'count': self.page.paginator.count,
            'lists': data,
            "page": self.page.number,
            "pages": self.page.paginator.num_pages,
            "pagesize": self.max_page_size
        })



# class PageNum(PageNumberPagination):
#     '''
#     自定义分液器
#     '''
#
#     page_size_query_param = 'pagesize'
#     max_page_size = 10
#
#     def get_paginated_response(self, data):
#
#        return  Response({
#            'count': self.page.paginator.count,
#            'lists': data,
#            "page": self.page.number,
#            "pages": self.page.paginator.num_pages,
#            "pagesize": self.max_page_size
#
#        })









